﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BikeManageBusiness.logical;
using Data.Common;
using Data.Enum;
using DataAccess.BikeManage.logical;

namespace BikeManageWeb.Pages.Account
{
    public partial class NewAccount : System.Web.UI.Page
    {
        /// <summary>
        /// 页面提示信息
        /// </summary>
        public PagePromptInfo pagePromptInfo = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                pagePromptInfo = null;
            }

        }

        protected void NewAccountStep1_Click(object sender, EventArgs e)
        {
            try
            {
                #region cpu卡连接
                int icdev = Zq58Logical.ZQ58_Connect();
                
                #endregion

                #region 二代身份证连接
                string stmp;
                int i, nRet;
                uint[] iBaud = new uint[1];
                i = Dkqa16dLogical.Syn_FindReader();
                if (i > 0)
                {
                    if (i > 1000)
                    {
                        stmp = Convert.ToString(i);
                        stmp = Convert.ToString(System.DateTime.Now) + "  读卡器连接在USB " + stmp;
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(200);
                        nRet = Dkqa16dLogical.Syn_GetCOMBaud(i, ref iBaud[0]);
                        stmp = Convert.ToString(i);
                        stmp = Convert.ToString(System.DateTime.Now) + "  读卡器连接在COM " + stmp + ";当前波特率为 " + Convert.ToString(iBaud[0]);
                    }

                    //将设备信息保存在application
                    
                }
                else
                {
                    if (pagePromptInfo != null && pagePromptInfo.PromptNumber == PagePromptEnum.Error)
                    {
                        pagePromptInfo.PagePromptDescribe = pagePromptInfo.PagePromptDescribe + "----" +
                                                            "二代身份读卡器联机失败！请确定设备是否连接正常！";
                    }
                }
                #endregion

                if (pagePromptInfo == null || pagePromptInfo.PromptNumber == PagePromptEnum.Success)
                {
                    Response.Redirect("NewAccountStep2.aspx");
                }

            }
            catch (Exception e1)
            {
                Application.Remove(ResourceLabels.ReCpuCardEquipInfo);
                Application.Remove(ResourceLabels.ReIdCardEquipInfo);
            }

        }
    }
}